<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<HTML>
	<HEAD>
		<meta http-equiv="Content-Language" content="zh-cn">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="${pageContext.request.contextPath}/css/Style1.css" rel="stylesheet" type="text/css" />
		<script language="javascript" src="${pageContext.request.contextPath}/js/public.js"></script>
		<script type="text/javascript">
		/*
			//1.创建异步对象
			//2.设置监听
			//3.打开链接
			//4.发送请求
			//window.location.href = "${pageContext.request.contextPath}/adminProduct_addPage.action";?time="+new Date().getTime()+"&oid="+oid
			//window.location.href = "${pageContext.request.contextPath}/adminOrder_findOrderItems.action?oid="+oid ;	
		*/
			function orderDetail(oid){
			   var but = document.getElementById("but"+oid);
			   var div = document.getElementById("div"+oid);
			   //alert(oid);
			   if(but.value == "订单详情"){
					 //1.创建异步对象
					var xhr = createXmlHttp() ;
					//2.设置监听
					xhr.onreadystatechange = function(){
						if(xhr.readyState == 4){
							if(xhr.status == 200){
								div.innerHTML = xhr.responseText ;
							}
						}
					}//"${pageContext.request.contextPath}/adminOrder_findOrderItems.action?time="+new Date().getTime()+"&oid="+oid 
					//3.打开链接//
					var url = "${pageContext.request.contextPath}/adminOrder_findOrderItems.action?oid="+oid+"&time="+new Date().getTime() ;
					xhr.open("GET",url,true);				
					//4.发送请求
					xhr.send(null);
					but.value="关闭";
			   }else{
				   but.value="订单详情";
				   div.innerHTML="";
			   }
				
			}
		
			function createXmlHttp(){
			   var xmlHttp;
			   try{ // Firefox, Opera 8.0+, Safari
			        xmlHttp=new XMLHttpRequest();
			    }
			    catch (e){
				   try{// Internet Explorer
				         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
				      }
				    catch (e){
				      try{
				         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				      }
				      catch (e){}
				      }
			    }

				return xmlHttp;
			 }
		</script>
	</HEAD>
	<body>
		<br><!--  action="${pageContext.request.contextPath}/user/list.jsp" -->
		<form id="Form1" name="Form1" method="post">
			<table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
				<TBODY>
					<tr>
						<td class="ta_01" align="center" bgColor="#afd1f3">
							<strong>订单列表</strong>
						</TD>
					</tr>
					<%-- <tr>
						<td class="ta_01" align="center" bgColor="#afd1f3">
							<strong>按用户查询：</strong>
							<select value ="" >
							</select>
						</td>
					</tr> --%>
					<!-- <tr>
						<td align="center" >
							<input type="button" width="30%" value="添加"  onclick="addProduct()"/>
						</td>
					</tr> -->
					<tr>
						<td class="ta_01" align="center" bgColor="#f5fafe">
							<table cellspacing="0" cellpadding="1" rules="all" border="1"
								bordercolor="gray" border="1" id="DataGrid1"
								style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; BORDER-LEFT: gray 1px solid; WIDTH:100%; WORD-BREAK: break-all; BORDER-BOTTOM: gray 1px solid; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #f5fafe; WORD-WRAP: break-word">
								<tr
									style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">

									<td align="center" width="5%">
										序号
									</td>
									<td align="center" width="5%">
										所用用户
									</td>
									<td align="center" width="5%">
										订单编号
									</td>
									<td align="center" width="5%">
										订单收件人
									</td>
									<td align="center" width="5%">
										订单地址
									</td>
									<td align="center" width="5%">
										订单电话
									</td>
									<td align="center" width="5%">
										订单总金额
									</td>
									<td align="center" width="5%">
										订单状态
									</td>
									<td width="10%" align="center">
										订单详情
									</td>
									<!-- 
									<td align="center" width="5%">
										编辑
									</td>
									 -->
									<td align="center" width="5%" >
										删除
									</td>
								</tr><!--	--> 
								 <s:iterator var="order" value="pageBean.list"  status="status"> 
									<tr onmouseover="this.style.backgroundColor = 'white'"
										onmouseout="this.style.backgroundColor = '#F5FAFE';">
										<td style="CURSOR: hand; HEIGHT: 22px" align="center"width="6%">
											<s:property value="#status.count" /> 
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											<s:property value="#order.user.username" />
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											<s:property value="#order.oid" />
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											<s:property value="#order.name" />
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											<s:property value="#order.addr" />
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											<s:property value="#order.phone" />
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											￥<s:property value="#order.total" />
										</td>
										<td style="CURSOR: hand; HEIGHT: 22px" align="center" width="10%">
											<s:if test="#order.state == 1" ><font color="black" >未付款</font></s:if>
											<s:if test="#order.state == 2" >
												<a href="${pageContext.request.contextPath }/adminOrder_updateState.action?oid=<s:property value="#order.oid" />" >
													<font color="red" >发货</font>
												</a>
											</s:if>
											<s:if test="#order.state == 3" ><font color="pink" >等待确认收货</font></s:if>
											<s:if test="#order.state == 4" ><font color="blue" >交易完成</font></s:if>
										</td>
								
										<td align="center" width="10%" >
											<input id="but<s:property value="#order.oid" />" type="button"  value="订单详情"  onclick="orderDetail(<s:property value="#order.oid" />)"/>
											<div id="div<s:property value="#order.oid" />" ></div>
										</td>
										<%-- 
										<td align="center" width="7%" style="HEIGHT: 22px"><!--${pageContext.request.contextPath}/adminCategory_edit.action?cid=<s:property value="#c.cid"/>  -->
											<a href="${pageContext.request.contextPath}/adminOrder_edit.action?oid=<s:property value="#order.oid"/>" >
												<img src="${pageContext.request.contextPath}/images/i_edit.gif" border="0" style="CURSOR: hand">
											</a>
										</td>
								 --%>
										<td align="center" width="7%" style="HEIGHT: 22px"><!-- ${pageContext.request.contextPath}/adminCategory_delete.action?cid=<s:property value="#c.cid"/> -->
											<a href="${pageContext.request.contextPath }/adminOrder_delete.action?oid=<s:property value="#order.oid"/> " >
												<img src="${pageContext.request.contextPath}/images/i_del.gif" width="16" height="16" border="0" style="CURSOR: hand">
											</a>
										</td>
									</tr>
								</s:iterator>
								<tr	style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3">
									<td align="center" width="30%" colspan="10" >
										 第&nbsp;<s:property value=" pageBean.page" /> /<s:property value="pageBean.totalPage" />页&nbsp;&nbsp;|&nbsp;&nbsp;
										<s:if test="pageBean.page != 1" >
											<a href=" ${pageContext.request.contextPath}/adminOrder_findAll.action?page=1" class="firstPage" >首页&nbsp;</a>
											<a href=" ${pageContext.request.contextPath}/adminOrder_findAll.action?page=<s:property value="pageBean.page-1" />" class="previousPage" >上一页&nbsp;</a>
										</s:if>
										<s:iterator var="i"  begin="1"  end="pageBean.totalPage" >
											<s:if test="pageBean.page != #i" >
												<a href=" ${pageContext.request.contextPath }/adminOrder_findAll.action?page=<s:property value="#i"/>" >
												 <s:property value="#i" /> </a>
											</s:if>
											<s:else>
												<span class="currentPage" > <s:property value="#i" /> </span>
											</s:else>
										</s:iterator> 
											&nbsp;&nbsp;<font color="pink" ><s:property value="pageBean.page" /> </font>&nbsp;&nbsp;
										 <s:if test="pageBean.page != pageBean.totalPage">
											<a href=" ${pageContext.request.contextPath}/adminOrder_findAll.action?page=<s:property value="pageBean.page+1" />" class="nextPage">下一页&nbsp;</a>
											<a href=" ${pageContext.request.contextPath}/adminOrder_findAll.action?page=<s:property value="pageBean.totalPage" />" class="lastPage">尾页&nbsp;</a>
										</s:if>
									</td> 
									
								</tr>
							</table>
						</td>
					</tr>
				</TBODY>
			</table>
		</form>
	</body>
</HTML>

